#include "Clock.h"
using namespace std;

//类的实现: 类中声明的函数定义出来
//要在函数名前面加"类名::", 显式说明该构造函数属于哪个类
Clock::Clock (time_t t) {
		tm * local = localtime (&t);
		m_hour = local->tm_hour;
		m_min = local->tm_min;
		m_sec = local->tm_sec;
}
void Clock::run (void) {
	while (1) {
		printf ("\r %02d:%02d:%02d", m_hour, m_min, m_sec);
		//刷新输出缓冲区
		fflush(stdout);
		if (++m_sec == 60) {
			m_sec = 0;
			if (++m_min == 60) {
				m_min = 0;
				if (++m_hour == 24) {
					m_hour = 0;
				}
			}
		}
		sleep (1);
	}
}
